package com.systar.activity.report.actions;

import java.util.Map;

import com.systar.activity.report.ActivityData;
import com.systar.activity.report.RequestParameter;

class PushData extends DataManipulation
{

	@Override
	protected void processData(ActivityData activity, Map<RequestParameter, String> parameters)
	{
		if (parameters.containsKey(RequestParameter.parsing))
		{
			String nbErrorStr = parameters.get(RequestParameter.parsing);
			int nbError;
			try
			{
				nbError = Integer.parseInt(nbErrorStr);
			}
			catch (NumberFormatException e)
			{
				nbError = 1;
			}
			activity.addErrors(nbError);
			System.out.println("Servlet push "+activity.getName()+" add "+nbErrorStr);
		}
		if (parameters.containsKey(RequestParameter.status))
		{
			boolean status = Boolean.parseBoolean(parameters.get(RequestParameter.status));
			activity.setActive(status);
			System.out.println("Servlet push "+activity.getName()+" status "+status);
		}
	}

}
